<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>编辑日常生活活动评估表</title>
	<#include "/common/resource.ftl">
    <link rel="stylesheet" href="${params.contextPath}/static/plug/layui/css/layui.css">
    <link rel="stylesheet" href="${params.contextPath}/static/css/jquery-ui.min.css">
    <script src="${params.contextPath}/static/js/jquery-ui.min.js"></script>
    <script type="text/javascript">
		$(function () {
            <#if (params.tag)??>
            $( "#elderName").autocomplete({
                source: function(request, response) {
                    $.ajax({
                        url: "${params.contextPath}/web/elder/listAll.json",
                        dataType: "json",
                        data: {
                            name: $("#elderName").val().trim()
                        },
                        success: function(data) {
                            response($.map(data.data, function(item) {
                                return {
                                    value: item.name,
                                    id: item.id
                                }
                            }));
                        }
                    });

                },
                select: function(e, ui) {
                    $("[name='elderId']").val(ui.item.id);
                },
                maxLength: 2
            });
            <#else>
            LocalStorage.registHandler("elder_handler_select", function (data) {
                $('input[name="elderId"]').val(data.id);
                $('input[name="elderName"]').val(data.name);
            });
            </#if>
			<#if (params.id)??>
				$.ajaxRequest({
					url: '${params.contextPath}/web/dailyLifeActivityAssessment/query.json',
					data: {id: "${params.id}"},
					success: function (data) {
						if (!data.success) {
							$.message(data.message);
							return;
						}
						var record = data.data;
						for (var key in record) {
							$("[name='" + key + "']").val(record[key]);
						}
						layui.form.render();
					}
				});
			</#if>
            $(".ajax-form").unbind().submit(function () {
                try {
                    var form = $(this);
                    if (!form.valid()) {
                        $.message("验证不通过，无法提交表单");
                        return false;
                    }

                    form.formSubmit({
                        callBack:function (data) {
                            <#if (params.tag)??>
                            history.go(-1);
                            </#if>
                        }
                    });
                } catch (e) {
                    console.log("表单提交错误：" + e);
                }
                return false;
            });
		});
	</script>
    <style>
        .layui-form select {display:none !important;}
    </style>
</head>
<body>
	<div class="ui-form">
		<form class="layui-form ajax-form" action="${params.contextPath}/web/dailyLifeActivityAssessment/<#if (params.id)??>modify<#else>save</#if>.json" method="post">
			<input type="hidden" name="id" value="${params.id}" />
            <#if (params.tag)??>
                <div class="layui-form-item">
                    <label class="layui-form-label">老人<span class="ui-request">*</span></label>
                    <div class="layui-input-block">
                        <input type="hidden" name="elderId" id="elderId" value=""/>
                        <input type="text" id="elderName" name="elderName" class="layui-input" autocomplete="off"/>
                    </div>
                </div>
            <#else>
                <div class="layui-form-item">
                    <label class="layui-form-label">老人<span class="ui-request">*</span></label>
                    <div class="layui-input-block">
                        <input type="hidden" name="elderId"/>
                        <input type="text" name="elderName" placeholder="请选择老人" p="model:'elder',handlerId:'elder_handler_select'" class="layui-input single-model-select {required:true}" readonly>
                    </div>
                </div>
            </#if>
			<div class="layui-form-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">进食情况<span class="ui-request">*</span></label>
                    <div class="layui-input-block">
                        <select name="eatScore" class="layui-input">
                            <option value="">请选择</option>
                            <option value="10">可独立进食</option>
                            <option value="5">需部分帮助</option>
                            <option value="0">需极大帮助或完全依赖他人</option>
                        </select>
                    </div>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">洗澡情况<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <select name="washScore" class="layui-input">
                        <option value="">请选择</option>
                        <option value="5">准备好洗澡水后，可自己独立完成洗澡过程</option>
                        <option value="0">在洗澡过程中需他人帮助</option>
                    </select>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">修饰情况<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <select name="retouchScore" class="layui-input">
                        <option value="">请选择</option>
                        <option value="5">可自己独立完成</option>
                        <option value="0">需他人帮助</option>
                    </select>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">穿衣情况<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <select name="wareScore" class="layui-input">
                        <option value="">请选择</option>
                        <option value="10">可独立完成</option>
                        <option value="5">需部分帮助</option>
                        <option value="0">需极大帮助或完全依赖他人</option>
                    </select>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">大便控制情况<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <select name="stoolControlScore" class="layui-input">
                        <option value="">请选择</option>
                        <option value="10">可控制大便</option>
                        <option value="5">偶尔失控</option>
                        <option value="0">完全失控</option>
                    </select>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">小便控制情况<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <select name="peeControlScore" class="layui-input">
                        <option value="">请选择</option>
                        <option value="10">可控制小便</option>
                        <option value="5">偶尔失控</option>
                        <option value="0">完全失控,或留置导尿管</option>
                    </select>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">入厕情况<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <select name="toiletScore" class="layui-input">
                        <option value="">请选择</option>
                        <option value="10">可独立完成</option>
                        <option value="5">需部分帮助</option>
                        <option value="0">需极大帮助或完全依赖他人</option>
                    </select>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">床椅转移情况<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <select name="bedChairTransferScore" class="layui-input">
                        <option value="">请选择</option>
                        <option value="15">可独立完成</option>
                        <option value="10">需部分帮助</option>
                        <option value="5">需极大帮助</option>
                        <option value="0">完全依赖他人</option>
                    </select>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">平地行走情况<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <select name="walkGroundScore" class="layui-input">
                        <option value="">请选择</option>
                        <option value="15">可独立在平地上行走45m</option>
                        <option value="10">需部分帮助</option>
                        <option value="5">需极大帮助</option>
                        <option value="0">完全依赖他人</option>
                    </select>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">上下楼梯情况<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <select name="walkStairsScore" class="layui-input">
                        <option value="">请选择</option>
                        <option value="10">可独立上下楼梯</option>
                        <option value="5">需部分帮助</option>
                        <option value="0"> 需极大帮助或完全依赖他人</option>
                    </select>
                </div>
            </div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<input type="submit" value="保存" class="layui-btn" />
				</div>
			</div>
		</form>
	</div>
</body>
<script src="${params.contextPath}/static/plug/layui/layui.all.js"></script>
</html>
